<?php
/**
 * Created by PhpStorm.
 * User: Xzareth
 * Date: 24/04/14
 * Time: 7:06 AM
 */
?>
<div id="userInfo">
    <?php

    $totalItems = 0;

    if (isset($_SESSION['id'])) {

        $user = $user->getUserInfo($_SESSION['id']);
        $firstName = $user['FirstName'];

        if ($secure->isAdmin()) {
            echo "<p>Welcome " . "<a href='admin.php' style='color: #AF7647 !important;'>" . $firstName . " </a></p>";
        }
        else {
            echo "<p>Welcome "  . $firstName . " </p>";
        }

        if (isset($_SESSION['totalItems']) && $_SESSION['totalItems'] != 0) $totalItems = $_SESSION['totalItems'];
        ?>
        <a href="cart.php"><img src="images/cart.png" alt="Cart" width="30" height="30"><?php echo '(' . "$totalItems" . ')'; ?></a>
        <a href="logout.php" style="color: #AF7647 !important;">Log Out</a>
    <?php
    }
    else {
        $pageName = basename($_SERVER['PHP_SELF']);

        echo '<p>Welcome ' . 'Guest' . ' </p>';

        if (isset($_SESSION['totalItems']) && $_SESSION['totalItems'] != 0) $totalItems = $_SESSION['totalItems'];
        ?>
            <a href="cart.php"><img src="images/cart.png" alt="Cart" width="30" height="30"><?php echo '(' . "$totalItems" . ')'; ?></a>
            <a href="login.php"><p>Log In</p></a>
    <?php
    }
    ?>
</div>



